package com.zwps.biz.domain.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zwps.biz.api.model.vo.reservoirInfo.ReservoirInfoVo;
import com.zwps.biz.dal.db.dao.ReservoirInfoDAO;
import com.zwps.biz.dal.db.dao.StRsvrfcchBDAO;
import com.zwps.biz.dal.db.dao.WrpRsrHychDAO;
import com.zwps.biz.dal.db.object.ReservoirInfoDO;
import com.zwps.biz.dal.db.object.StRsvrfcchBDO;
import com.zwps.biz.dal.db.object.WrpRsrHychDO;
import com.zwps.biz.domain.service.ReservoirInfoService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.configurationprocessor.json.JSONObject;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Optional;

@Service
@Slf4j
@AllArgsConstructor
public class ReservoirInfoServiceImpl  extends ServiceImpl<ReservoirInfoDAO, ReservoirInfoDO> implements ReservoirInfoService {
    @Autowired
    private ReservoirInfoDAO reservoirInfoDAO;
    @Autowired
    private WrpRsrHychDAO wrpRsrHychDAO;

    @Override
    public ReservoirInfoVo getByStcd(String rscd) {

        ReservoirInfoVo byRscd = reservoirInfoDAO.getByRscd(rscd);
        if (byRscd == null) {
            return new ReservoirInfoVo();
        }
        WrpRsrHychDO wrpRsrHychDO = wrpRsrHychDAO.selectById(rscd);
        byRscd.setNRSTLV(wrpRsrHychDO.getNrstlv());
//        byRscd.setDAMEL(stRsvrfcchBDO.getDamel());
        byRscd.setTTCP(wrpRsrHychDO.getTtstcp().divide(new BigDecimal(10000), 10, RoundingMode.HALF_UP));
        return byRscd;
    }

    @Override
    public String getVideoURL(String rscd) {
        QueryWrapper<ReservoirInfoDO> wrapper = new QueryWrapper<>();
        wrapper.select("VIDEO_URL").eq("RSCD", rscd);
       return reservoirInfoDAO.selectOne(wrapper).getVideoURL();

    }

}
